package com.example.tests;

import java.util.Collections;
import java.util.List;

import org.testng.annotations.Test;
import org.testng.Assert;

public class GroupCreationTests extends TestBase {
	
	@Test(dataProvider = "randomValidGroupGenerator")
	public void testGroupCreationWithValidData(GroupData group) throws Exception {
		app.getNavigationHelper().openMainPage();
	    app.getNavigationHelper().gotoGroupsPage();
	    
	    List<GroupData> oldList = app.getGroupHelper().getGroups();
	    
	    app.getGroupHelper().initGroupCreation();
	    
	    app.getGroupHelper().fillGroupForm(group);
	    app.getGroupHelper().submitGroupCreation();
	    app.getGroupHelper().returnToGroupsPage();
	  
	    List<GroupData> newList = app.getGroupHelper().getGroups();
	    
	    oldList.add(group);
	    Collections.sort(oldList);
	    Assert.assertEquals(newList, oldList);
  }
}
